Refactor hw detection