Madhu's code as of 18-Dec