changed mac check logic to be more efficient