fixed prototype for get nextAvailIndex and implemented nextAvailiNodeIndex