factory method source code