better check for errors; check if sub-node is dir; added comments;