re-factor scheduler