added debounce function