refactoring replace -> match