Fixing manageNodes for random move

Since random move will have node.type empty then it will be fixed by
filling by the previous node type
Fixing loop problem

when checkPathLoop the for loop should finish do their task first
before they can go to another checkpathloop