refactored possible moves function