Made few changes and added comments