Work in progress on writing to the database