Move some function to utils.h