added regularized cost function