sub functions