added functions and comments