Fixes the debounce function to work properly when leading is true by adding a condition to reset and reschedule the timeout whenever a subsequent call happens whithin the delay timeframe.