fixed vertical scrolling and cleaned up code