remove duplicated code
format