code to compute accuracy function