Refactored expression evaluation into functions.