fixed bug in remove function