Added more comments to explain code