Still Buggy - Code simplification done.

1. I don't think there is any obvious silly mistake.
2. Need to check for the numerical accuracy of the method.