simplified code (made a text formatter class)