prevent undefined from being saved to localstorage