wip: almost correct cost function; no estimation function as of yet