factor out text routines to text module