This code is now duplicated over three methods, perhaps it could be extracted?