add listener for button functionality, optimize time intervals