changing the __dirname and __filename api to dirname() and filename() because of race conditions with the value of __dirname