This line seems weird. `dir.equals(dir)` is always true. I assume one `dir` is supposed to refer to the parameter of the closure, rather then the parameter in the function? I think you have to rename one of them to make them work properly.