First set calculation working- Anyway likely to fail in corner cases which has to be fixed.