Avoid Maximum call stack size exceeded