refactoring to support multiple platforms