updated code to clean up modals