Finally adding error handling.