refactored ajax calls