refactor some code, no functionality change