fixed bug in remove code