implemented recursive input