added some logging when it saves to the database