removing reduntant code and asiigning value of id in local variable