added some checks to avoid illegally formatted data to be saved