added head and tail and did more stuff for print and random