checking for null pointers, some additional work still to be done