port done, need to adapt to standalone
adapted to standalone mode