Refactor: Moved inline pre handling code for text element to a class