reimplement register_component function with templates