changed error handling and added write check to QueryEids()