working code updated for fault tolerence