added initial version (from http://www.hexblog.com/?p=128)