Make the exists method a little more general.