refactor, remove some duplicate lines.