Separate left / right movement into a function