my implementation of a scheduling algorithm