add check for null ptr