better error handling in case of missing directory