finished steepest decent algorithm