corrected reference to data variable for error handling