divide plural s earlier

divide plural s earlier (outer, more near to top/root)

move some codes into new functions