further work on summary scripts - 80% confident it now works