improved srid logic

Patch from Alex Trofast