switch instead of if and traces cleanup