refactoring code in search for more independent structure.