fixed undef method for nil error