refactor code of player