use error logging better