added ajax calls to the code