Updated AJAX functionality to update better and optimized some JS