updated script based on recent changes