copy paste warning, please reorganize those functions to one.