check for directory before attempting to read in resource type + better error handling