added timeout that works; added nicer error messages
fix bug: strange error on nil input