use find for dir detection instead of test, hopefully saving some memory at the same time