added some AJAX and fixed a bug