I know you're just moving code around, but this should really distinguish between the "err != nil" and "!ok" cases