How to make the duration of a routine fixed?