There was a time when every junior doctor in Scotland took it for granted that they had to work long, gruelling shifts.

Often they would have no sleep, little or no rest, and sometimes not even enough time for food or drink. It was bad for the doctors and bad for patients too.

Then the law was changed by the European Working Time Directive and no-one in the UK was supposed to work more than 48 hours in a week. It was a good idea in theory but, in practice, health boards worked round the legislation, leaving doctors to carry on trying to do their best while working long, exhausting weeks.

The case of Lauren Connelly last year highlighted the terrible potential consequences of that approach. Dr Connelly died while driving home from Inverclyde Royal Hospital in Greenock after she had worked 10 days without a day off. In the aftermath of her death, her father Brian Connelly and experts such as Ian Ritchie, chairman of the Academy of Medical Royal Colleges and Faculties in Scotland, added their voices to the growing calls for change.

The Scottish Government insisted it was doing everything it could to ensure health boards were abiding by the directive, even though some hospitals were giving their doctors a few days off so that, over six months, their average week did not exceed 48 hours. It was obeying the directive on paper, but not in spirit.

Health Secretary Alex Neil has indicated a welcome change of direction. The restrictions on working hours are an improvement on existing practice, meaning that, by February next year, no doctor should have to work for seven full night shifts in a row. Furthermore, by 2016, no doctor will have to work more than seven day shifts in a row either. This does represent a significant change, and a step forward for doctors and patients, and Mr Connelly in particular deserves praise for helping to bring it about. It was not easy for him to go public and talk about his daughter but it has helped change the culture at the top. In a letter to all health boards, Paul Gray, the chief executive of NHS Scotland, has made it clear that all junior doctors should be well rested and fit for work. This might seem like stating the obvious but, on many wards, managers had to take account of several factors, including staffing levels, that made it difficult to tackle a long-hours culture.

The change of mind by the Scottish Government does not mean the problem is solved, of course. Vigilance will be required to ensure hospitals do not try to avoid the new rules in the way that some have worked round the directive, and that might require a strengthened role for Healthcare Improvement Scotland. If the change of policy is to work, hospitals will have to be monitored as part of a process that also makes junior doctors feel able to speak out when they need to.

The signs are promising, however, for an improvement to junior doctors' working conditions. Mr Connelly believes his daughter died because she was tired from all the hours she had been working. No doctor in the NHS should ever be put in that situation again.