extract muting behavior into seperate functions and fix loop