Added error checks
Possible to pass client ip parameter