Fix stack overflow