removed duplicated code.