added better tail support