Re factored code.  Made better use of the EditDuration function.