some refactring.