making jquery synchronous