remove the null tail