made every script into a function