Update groups.php

Improved error handling