generalize reflection logic