[fix] better implementation of has_element