cost function modified