Figured out the bug that caused the calculation to occur multiple times.