fixed dirname/basename problem