some code refactor