added regularization to cost function