Added case2 and tested in small scale database. Not sure if the numbers
are correct but there's consistency in both tests.
Also removed the bug where there can be division by zero.