lightly refactored