refractored Ajax calls