some refactoring and more work on textual