adding error handling.