added regularization to the cost function