an improved debounce implementation