Moved the working functions to the right files