fixed a bug about time calculation