updating saveToLocal methods with a loop on the boolean registred in local chose between insert and update query