implementing tail and setHead