fix dir path bug
fix bugs, organize code