added functions to clean up code