text processing and db logic