Made minimal changes and added comments