replaced some ToObject's with check-and-throw