Fixed a bug in the remove_range function