Move gsub to a separate method