implemented two kinds of simple factory