Added Comments and refactored.