shifted the codes to after id is retrieved