add more checking into factory