minor bugfix in add funtion