Remove duplicated code.