refactoring of tielsource code