Added logic for up and down buttons