added keysLength mediate var in case undefined error