added event handlers for y position and cleaned up code and comments