implement most of global functions