fixed insert text logic