code suggested by  webgaming developer cookbook