move some functions to AJAX-based controller.