calculator refactor