Moved tail to seperate general function