added error handling for None case