add memory detection