updated script for newer versions