sanity check
move variable definitions to the beginning of the function.