added comments to explain refactoring choices