Tested on Python2.4 and modified for operation on that version