remove duplicated code
remove duplicated codes