Everything working need to do tests also maybe do better than midpoint estimation