Refactored collect_moves to be more efficient