Moved all functions to its own files