Fix bug in more general case