added comments to the rest of the code

also fixed the flow chart