fixing order of calls to not break IMP handler