add error handling to APIwrite
added error handling to APIwrite
added comfilter to env_B