Refactor complex expressions into functions so that the rational can be understood better