My version with more comments

Have further commented the code