uploaded refactored solution only, reflection