added comments to key encoding