updated documentation
updated documentation and comments, added swap function
updated documentation