replaced nchain() with nchains()