Finished the SRTF function