add error test for when