refactor class factory build method