reworked input reading