Fix gsub for space detection