refactoring Tokinization logic