added error handling for db lookup