Put ndata and s as function internals