properly handle folders