refactored liberties method in board