Made the code look more pretty. Added documentation.