refactored joypad example