improved input reading