fix bugs of here document