Updated the code to show previous categories as preselected