refactoring of ajax calls

less and prettier code