Refactor with AJAX