Finally fixed edit preferences function