improvement script  

Add check memory and permission method