Merge pull request #12 from Sarith21/master

Fixes early-exit bug