added threaded/nonthreaded option at top level