remove duplicate code
remove more duplicated code