working code -MCM