refactor soultion of throttle and debounce