added a parseTails() function