fixing saving data to tables