Fix error in remove element and add comments