swapped variable and function script code