refactor the calculator