refactor and unit test the player
the example is missing a newline