Heard that slice is slow so made own tail function