moved out some function utils