Refactored a little and added reflection