Refactored code to comply with style guidelines, and for efficiency.