factored out common element creation procedure into separate function