fixed an issue that causes infinite loop