finished open and close button function