enable setting default dirname in constructor
change function definition order