Fixed a bug with add_element and removed a useless variable