Rewrote to use map_elements

not tested