minimize loop checking for prime