move some logic to component factory