This should appear outside `if ($rs)`
More logical code order