introduce stdin source, routine monitoring, and error handling