Fixed error on undefined string replace()