Replacing dir constant with dirname method