removing algorithm