commited initial code from http://j4p5.sourceforge.net/