Refactoring of battleship program