Refactoring 
Added comments in js code