Move ua detection logic