updated perplexity, error checked