re-incorporated lucas' earlier fix