swap some var order so we're not using stuff before it's defined