Added error handling to dirEntries