Move forward/backward code into separate functions.