added clarity to the code, fixed minduration > maxduration.