cleaned up to conform to PEP8, added comments, renamed variables