Refactor firetext.js