generic verify function