Moved target format calculation earlier in file