add unique index for combination of source id and ip address
Add docstring and update error checking