fixed null pointer dereferencing