This code is repeated, so it would be best to refactor it.