Optimization at add and remove method.