Fixed global variables startNode and endNode