implement endplay code