copied fix from @gchandrasa