fix bugs and use path resolve