refactored code, unnecessary call to repeat command when using <up> only once