added channel if-statements for clarity