imporved check prime code