fix bugs for running in different dir