simple debounce algorithm