move element creation into a factory class.