adds functions to cure inconsistencies between json and db