code from http://www.yellosoft.us/evilgenius/