Moved function to save to database to correct location. Untested.