Patrick Ottley-O'Connor was looking for a "doer-upper" - a school where he could make his mark by bringing it up to its full potential.
The 44-year-old wanted his first headship to be a test. He cut his leadership teeth with two terms at a school for pupils with emotional and behavioural difficulties, heading rapidly towards special measures.
A short spell as acting head pulled the school back from the brink and, more importantly, ensured he "got a taste for a challenge".
Todmorden High School seemed perfect. The 750-pupil comprehensive had just scraped through an Ofsted inspection with a "satisfactory" verdict and numbers were falling. But there was a #163;400,000 budget surplus to play with and, as head of the only secondary in the Pennine mill town of Todmorden, Mr Ottley-O'Connor had plenty of scope for attracting more pupils.
But within weeks of starting as head in January 2007 he uncovered "a bit of a problem". The surplus didn't exist. Todmorden High was actually heading for a #163;2 million deficit and the only solution was to slash teacher numbers by more than a third.
Today, more than three years later, Mr Ottley-O'Connor is preparing for his next job as principal of an academy in Salford from September.
At Todmorden he will leave behind a secondary on the up. Exam results have improved dramatically, Ofsted is happy and the flow of pupils leaving the town to receive secondary education elsewhere has been stemmed.
Even more impressively, Todmorden High is at the centre of a renaissance that is bringing the whole town together around one of life's essentials - food.
The head has been a prime mover in a grass-roots environmental movement that has brought Todmorden national and international prestige. But it could so easily have been very different.
When Mr Ottley-O'Connor discovered the hand he had really been dealt back in 2007, he admits his first reaction was to leave.
The truth emerged gradually as he began to look at the staffing structure.
"Six weeks in I realised it didn't add up," he said. He calculated the school would have a deficit of #163;450,000 in three years. After 60 days in the job that projection had doubled to #163;900,000, and by his 100th day he worked out that his new school would end up #163;1,957,000 in the red.
"There was a massive overspend," he said. "I didn't know it, the governors didn't know it and the local authority didn't know it.
"I thought it was my fault. I thought I had done something wrong. But the authority and the governors should have known.
"I told the director (of education at Calderdale Council) that I felt misled. I almost walked."
But spurred on by the support he then received from his governors and the council, he decided to stay on to try to implement his original vision for the school.
He was anxious that pupils and staff "who had done nothing wrong" shouldn't suffer. Yet there was only one way out of the mess.
"When I first told staff of the issue I stood in front of them and I filled up. I found it very difficult. I looked round thinking 'I am going to have to make some of you redundant'."
The numbers were stark. Mr Ottley-O'Connor needed to reduce the number of full-time equivalent teachers from 65 to 43 and support staff from 70 to 59.
At one stage, it looked as if 15 teachers would have to be made compulsorily redundant and the school faced two days of strikes by NUT members.
"It was a lash out," the head said. "But the staff realised why we were doing what we were. They never blamed me."
He remembers a car journey he took just after realising he would only have to make five compulsory redundancies.
"I was euphoric. Then I suddenly thought they are still five real people with mortgages and families." He pulled into a layby and broke down.
With the budget issue finally resolved - he eventually reduced compulsory redundancies to two - Mr Ottley-O'Connor was able to get on with what he had originally set out to do and raise standards.
His first task was to improve the school's image. A quarter of Todmorden's secondary-age pupils were leaving the town every day to attend better-regarded Calderdale comprehensives, grammar schools in Halifax, private schools, or state schools in Burnley and Rochdale. Anywhere but Todmorden High, which had effectively become fifth choice.
It was the kind of situation you might expect in inner-London, where long commutes to school have become the norm for pupils with parents desperate to avoid certain secondaries.
But it wasn't right in Todmorden, a proud and distinctive town of some 17,000 people. Mr Ottley-O'Connor needed them to get behind their local school again, to make it the obvious choice for their children.
And that meant appealing to a wide constituency. Todmorden is full of contradictions. It sits right on the Yorkshire-Lancashire border and has red rose Oldham postcodes and Rochdale phone numbers, despite being part of the white rose county.
Like Hebden Bridge, a few miles down the spectacular Calder Valley, the town has drawn in middle class migrants with its cheap ex-mill worker housing and attractive barn conversions on the hills, all within easy commuting distance of Manchester.
It also resembles its neighbour in having developed something of a reputation as a centre of alternative, counter-culture. As one resident jokes: "Hebden Bridge is the sort of place where those people who said they did drugs in the 1960s live. But the people that (actually) did drugs in the '60s live here."
But at the same time Todmorden remains a working-class ex-mill town lacking an industry, with all the multiple deprivation that that entails.
Mr Ottley-O'Connor had to bring all these strands together. "You've got a school that's gone down the pan standards wise - where's its credibility?" he asks. "Then the new head tells you that it's going to lose 20 teachers. Why would you send your kids there?"
The answer arrived in the form of community activist Pam Warhurst. A whirlwind of energy, the former Calderdale Council leader had decided she wanted to do something to promote sustainable living that went beyond the usual rhetoric and made a practical difference.
She hit on the idea of using that most basic of human needs - food - as a way of getting the whole community involved. The Incredible Edible Todmorden campaign she co-founded has since won international recognition for the way it has encouraged people to grow, cook and eat locally produced food.
But to get it off the ground it needed a focal point, which Todmorden High and Mr Ottley-O'Connor were happy to provide.
"I had a school that was dying on its back," he says. "I needed to do something."
Ms Warhurst also found a comrade in arms in Tony Mulgrew, the school catering manager who was already keen to introduce local food onto the menu. A parallel process began to take place in the curriculum, with the subject of food incorporated into a wide variety of lessons.
Incredible Edible was able to reach out to parents through the school's pupils and by using Todmorden High as a wider community resource.
And for Mr Ottley-O'Connor the campaign "gave credibility to what we were trying to do and it caught the imagination of the community".
The thread runs throughout the secondary - from a poll on the website asking whether the school chickens should be killed and then served in the canteen or sent to retire on a local farm, to the flowerbeds throughout the grounds that have been replanted with vegetables.
This year, the school won a grant that will allow it to turn a large site behind the main building into what Mr Ottley-O'Connor says will double up as a "massive outdoor classroom" and a food centre for Todmorden as a whole.
It will include a sustainable fish farm, fruit orchards, polytunnels and vegetable patches. Pupils have been heavily involved from the start, ensuring that their imaginations have been captured by the project and the transformation of their school as a whole.
"When I started in Year 7 everyone saw it as the rubbish school in the area so it meant the students felt like rubbish and that nothing was expected of them," says 18-year-old Aisha Coggan. "Now things are changing and people are proud that they come from Todmorden High. People can achieve here and they do achieve here."