Remove repeated code.