merged with saurav's code