Changed primary check after I found a catastrophic bug in the old method.