reflection and refactored solution