/** code by Sam */