refactored ttf logic