fixed and added comments to logging part