Factory pattern to constract the output objects