Improved text function.