refactoring of platform-specific code