JS filtering code to repopulate data