Fix for stack overflow