Fixing a bug introduced in the extension of 'apply in' + simplifying code.