reordered functions in a more logical order