Changing to a url_for to make it work with the buttons
fixing the code and targets for the buttons