check for null pointers

model can sometimes be null