Implemented the logic to generate the list of buttons