Fixes bug with scheduler