You are accessing res.code even when res can be ```nil``` without checking it first.