Added comment and wrote functions