separate some useful function to  internal