make replace, top and max_element features work together