Fix bug causes plugin to crash