Added docs, and redeclared function in main