updated the save method to better use dirty tracking