adding Jens Erat's function to build from list of elements