Let's extract this to a method so it's not repeated above.