fixed sort order and time gap error