make cost and beam consistently const& params