found error in cost function increasing when corrected