Fixing a new bug after changing the scheduling finction in the last commit