tidied up node code