do isDirectory check earlier, fixes #51
0.5.2