adding defensive checks
adding comments
inserting break
Merge pull request #123 from raghavgautam/master

adding defensive checks