Refactor looking along a row into a separate method with a parameter for the direction to search.