removed unnecessary code from function popHead and popTail