Modified code for assignment 2 by Mangesh