Corrected variable name and exception handling