code refactor & fix exception widget NPE