updated for editing existing node aswell