refactored expression replacement