Successfully integrated Daniel;s code