scusa nella mia funzione c'è un baco...
nella riga

return nextID -1

ciao