psuedo code for khanna added