moved function above function call