Moving functions to where they belong