removed duplicated code