refactored timestamp code