fixed the Stack overflow error