Stack overflow fixed