Resolves #7, moved functions out of main into their own files