Change selection gaps algorithm to us DOM based approach too