modified from sukumar vidya first
resoled conflicts and merged