Completed the output calculation code. Only one function left to implement.
Merge remote-tracking branch 'origin/master'