added debounce to avoid too much clicking by the user