added null check to prevent nasty paint exception