add closed to handling events, refactor use