Move repetitive code for King movement to a separate method