corrected scope problems with ajax