use defer to free memory...// fix file permission