changed script to be more generic