Faster code for plotDetFunc