Refactored code to be more consistent with organization of documentation