Duplication in source code is a widespread phenomenon that increases program size and complexity, and makes program maintenance more difficult. A solution to this problem is to detect clones (instances of copied code) and to eliminate them. Elimination works by extracting the cloned code into a separate new procedure, and replacing each clone by a call to this procedure. Several automatic approaches to detecting clones have been reported in the literature. In this paper we address the issue of automatically extracting a previously detected group of clones into a separate procedure. We present an algorithm that can extract "difficult" groups of clones, and a study that shows that difficult clone groups arise frequently in practice, and that our algorithm handles them well.