fixed remaining resources calculation