fixed a small bug when adding an element