refactored ctx files