refactor for multiplatform