Improved bad selection causing issues when inserting HTML