move up-down arrow code to backend