adding error handling in retrieval