clear the table only at the end of the on() call

no need for code duplication