refactory send reply code.