Original version. Coded both functions in the file.