updated code according to Fernando's comments
updated code according to Arthur's comments
update typo comments