Added more documentatin and comments in the code