ajax call and some minor bugs