Refactored and Documented