refactored some code and created calculator