Use $dir instead of $fullpath