fix the button bugs and add comments