You don't need the "to_i" when working with res.code, it's already a number