fix bugs in name assignment