refactoring for portabilty