add scheduler code to handler