reverted previous fix, it was bogus; applied similar changes at better location