Fixed broken plugin due to too many end statements