code.c

Logic is improved and code is now more reliable
Merge pull request #1 from Deepanshu2017/patch-1

code is now more reliable and performance is improved!