Better prime finding function