fix path issue and refactoring