Made AJAX work properly