updated getip-method with try-statement