Fixing error: NoMethodError - undefined method `gsub' for nil:NilClass