ported newer code