Refactored the code to use platform.contains() to simplify it