removed unnecessary line setting prev = head instead of just commenting it out