reordered functions so we do not use before we define