added more comments to readability of code