restored correct end