How to write your own debounce function