player js refactor