scheduler code WIP