Fixes #10 by handling invalid inputs without crashing