Completed functionality to prevents unneeded AJAX requests