move reflection code outside.