Factoring out the creation of the element
Added error and clean styles