Added haddock documentation to each function