Implemented majority of calculations