fixed bug #71 by adding validation checks
Merge pull request #72 from stanzheng/master

fixed bug #71 by adding validation checks