Added removetail() function