fixed the calculator logic