bugfix in remove function