Add checks that input exists and is valid.
Merge pull request #2 from moonandfox/master

Add checks that input exists and is valid.