removed duplicated logic