fixed NPE
made a little rewrite other schedulers are going soon to.