Function for calulating channel length.
added comments