Fixed a bug in evaluating primary contact