Better str-replace function