changing __dirname to dirname() to prevent race conditions in config files