fix key length check