improved code of AdvancedCalculator