Bug fix for the string_replace function