added functions to main