mistake in cost function