fixed bug: double cost is for b, not for a