check pointer before drawing