add functional buttons and sorting