Add painted flag check