replaced old code