refactor
changing an empty buffer calls insert