some refactoring to make it easier to work multiplatform