refactoring of user_ip method