fixed some bugs in calculator