rewrote procedure that adds histories to database