added shutdown function