script modified based on recent updates