additional debugging. cleaned up how  is calculated