Updated code to handle undefined variable which was previously caught by
rescue.