add time handling function