finish reply function.need to be refactor