added some of abhi's code