Refactor button insertion