implemented insertNode