Correct error in send packet. Refactoring