simplify codes for better performance, support raw text