added all of Dipti's code