Refactored the code according to the comments
Refactored the code according to the comments and removed conflicts