generalized and fixed up localstorage server