Added a check to avoid issues with AJAX #21