How to make my calculator more efficient?