refactor finding insertion point

now using ranges instead of traversing the dom