Implemented the more complicated calculations