refactor sharedpreferences implementation