some refactor work