Added a print function
Added NameError for undefined variable