cleanup delete logic
js refactor