Fix maximum call stack error