Channel detection function completed and tested