add code reassignment logic