rewrite scheduler