added more documentation and better formating