adding O(1) rectSum, need debug