implementation of a simple factory