A configurational-bias approach for the simulation of inner sections of linear and cyclic molecules