Add debounce function

Add debounce capability

fix partially the 1) of #688