adapted to make it portable across platforms