added right button and cleaned up code