check for object before writing and multipleobjects found exception handler