fixed detectDevice