refactor code, take the check part befoer getting deviceInfo