Made the code always appear at the head and removed duplicate codes