refactored code for computer moves