improved remove and add code