outsourced input handling
added proper error messages