Refactor the tex