started calculating f, g, and h vals