Refactored reflection code