Refactoring isolate function