optimize play code