Added the new code from 06d2a64