skip timestamp checking if not required, remove duplicate code

1) No need compare all timestamps when all the values are within range
2) remove redundant code.