remove tabs and improve tab detection