improve up/down key functionality