added split tail function