working code using only 1 instance of calculator