Added begin/rescue block around the gsub call