startTagInBody function optimized