refactor arithmetic operations into reusable fn