adding up and down arrow functionality and some refactoring in controller