adapted this fix to new specifications