extracted reusable code into datachannel package and conforming to Golang standards.