patched a bug in time calculating