add debounce function and change some variable name