major refactoring done.