added some error handling for time