Made some changes to the codes