Added reformatted and refactored code.