refactor title code