Moving functions to a more logical place