cleaned up file by removing comments and unused code, no apparent bugs when tested