Reordered functions to be more logical