a bit more re-org and fix to text not termination error