added a condition to check if channel is null