update script- function def has to come first