added error handling for non-valid mongo id