factory logic