Rearrange code, add location pull