restored working code