fix nil dereference