added remove_sparse function