Fix #2. Add check for invalid input
Merge pull request #3 from mkozakov/master

Fix #2. Add check for invalid input