fix file save bug and refactored directory