Fixed the while condition and schd methods

Fixed the scheduling methods