revised carving logic