removed reverse functionality, removed unused variables, cleaned up code a bit