Added functions and comments