fixed bug which caused failure on ill-formatted inputs