added ported code