Refactor of text module