Fixing function that doesn't check if object is nil

Jake's migration on dev drew attention to this.