refactored retrieving client ip