Fixed remplace function pattern matching