Added documentation

Added comments to show what the methods do and to make the code more readable.