Fix max callstack issue

Fix the max call stack exceeded error.