final revision to device detection