fixed some bugs in the calculation method. It still needs to be looked through for a speed up though. Probably in the decomp method