Don't call isdir() every time