added debounce function, fixed ajax calls, refactored hiding and showing