working code - parthesh