refactored player code into separate object