multiple queries replaced by single one

one query will retrieve both userid and IP . and throw exception in case of any IP mismatch.