fixing loop token insertion and editing