previous refactoring introduced a bug. Now fixed