created readLocal and writeLocal functions