num_osds is never changed, should be using i instead