some refactoring done.