add error logging; fix bug selection