fixing issue 781 (do not review yet)