fix nil image checking