fix file path bug, improve code