modularize the playing function (mostly)