Code for the scheduling, maybe works?