JS rework + AJAX sorting