incorrect comparison when checking err (how embarassing!)