Simple implementation of factory method pattern