Made prime checking slightly more efficient
this should work