cleaned up code for read & write nodes