Fixing return statements of getNextNode()