Fixed indetations, added nextId() function, removed debugging print outs