Don't access localStorage directly in case it's not defined