Updated version (cherry picked from commit 3624499)