Added comments to make code more clear