Fixed stack overflow error