generalized to different ns