created button function and refactored jquery