Corrected handling multiple handlers

(cherry picked from commit 7bce797c06f4b6751fa1e9464cf2281c903510d1)