fix nil handling