fix a bug in remove function