added alternative cost function feature