adding log-cost functionality