This is my first edit with the completed functions,properly commented and hopefully my last