ip refactor - update sql