factory method pattern implemented with an error