Refactor platform detection