move scheduler into lib