How did Hubble use cepheids to measure the distance to M31 and other galaxies?