Correctly adds output to database.