added functions to cleanup code