Fix `Max call stack size exceeded` error