Fix for unexpected 'end'