changed HMAX back to difference between t0 and tf