refine code for player