move debounce to seperate function