fixed a bug with the dirname method