refactored tex