[TASK] Refactor code, check for completed before triggering badge event