update user/copy file permissions and refactor some code