Added logic and event listeners for calculating.