add cost test function