Added key length function