added error handling and timestamps